package com.chengqs.rainbow.auth.api.impl;

import com.chengqs.rainbow.api.auth.AuthApi;
import com.chengqs.rainbow.auth.service.TokenService;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.security.jwt.crypto.sign.InvalidSignatureException;

/**
 * <B>主类名称：</B>AuthApiImpl<BR>
 * <B>概要说明：</B>enter<BR>
 *
 * @author: chengqs
 * @create: 2025-09-15 21:50:32
 **/
@Slf4j
@DubboService(version = "1.0.0", interfaceClass = AuthApi.class)
@RequiredArgsConstructor
public class AuthApiImpl implements AuthApi {

    private final TokenService tokenService;

    @SneakyThrows
    @Override
    public boolean authenticate(String token) {
        try {
            tokenService.authenticate(token);
            return true;
        } catch (InvalidSignatureException e) {
            return false;
        }
    }
}
